-
Notifications
You must be signed in to change notification settings - Fork 847
[BUG FIX] Preserve model context across agent handoffs and background tasks #208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fixes #191 This commit addresses three critical issues with model selection: 1. **Background Agent Manager Model Preservation** - Updated BackgroundTask and LaunchInput types to include parentModel field - Modified manager.ts to capture and store parent model context - Updated notifyParentSession() to pass model field when resuming parent session - Background tasks now preserve the user's selected model across continuations 2. **Librarian Agent Factory Pattern** - Converted librarian agent from static config to factory function - Added createLibrarianAgent(model?: string) with configurable model parameter - Maintained backward compatibility with exported librarianAgent constant - Updated utils.ts to use the new factory function 3. **Background Task Tool Model Context Capture** - Updated background_task tool to capture current model context - Uses findNearestMessageWithFields() to get model info from parent session - Passes parentModel to manager.launch() for proper context preservation Changes: - src/features/background-agent/types.ts: Add parentModel field to BackgroundTask and LaunchInput - src/features/background-agent/manager.ts: Store and preserve parent model context - src/agents/librarian.ts: Convert to factory pattern with configurable model - src/agents/utils.ts: Use createLibrarianAgent factory - src/tools/background-task/tools.ts: Capture and pass model context - assets/oh-my-opencode.schema.json: Regenerated schema Impact: - Users with OAuth providers (Google, Anthropic) will now have their model selection preserved - Background agents no longer revert to hardcoded defaults - Agent model configuration is now more flexible and user-controllable Testing: - All existing tests pass (20/20) - Build succeeds with no errors - Backward compatibility maintained
|
@sisyphus-dev-ai hey pull rebase and resolve conflicts push bro |
|
👋 Hey @code-yeongyu! I'm on it... |
|
@sisyphus-dev-ai hello? you must resolve ulw |
|
👋 Hey @code-yeongyu! I'm on it... |
|
@sisyphus-dev-ai hey. said you to work. |
|
👋 Hey @code-yeongyu! I'm on it... |
|
@sisyphus-dev-ai hey, please resolve conflicts |
|
👋 Hey @code-yeongyu! I'm on it... |
|
✅ Conflicts resolved! I've created PR #229 with the resolved conflicts: #229 What was resolved:
All agents now use consistent factory pattern! 🎉 Verification:
The resolution preserves your PR's goals (model context preservation) while incorporating dev's parallel improvements (factory pattern for other agents). |
Summary
Fixes #191 - Resolves model selection reverting to hardcoded Anthropic models instead of preserving user's OAuth/configured model across agent handoffs and background task continuations.
Changes
1. Background Agent Manager Model Preservation
src/features/background-agent/types.ts: AddedparentModelfield toBackgroundTaskandLaunchInputinterfacessrc/features/background-agent/manager.ts:parentModelwith fallback tofindNearestMessageWithFields()for resilience2. Librarian Agent Factory Pattern
src/agents/librarian.ts:createLibrarianAgent(model?: string)DEFAULT_MODELconstantlibrarianAgentconstantsrc/agents/utils.ts: Uses newcreateLibrarianAgentfactory3. Background Task Tool Model Context Capture
src/tools/background-task/tools.ts:findNearestMessageWithFields()parentModeltomanager.launch()for proper context preservationImpact
✅ Fixes
🔧 Technical Improvements
🛡️ Backward Compatibility
Testing
Files Changed
src/features/background-agent/types.ts- Add model context fieldssrc/features/background-agent/manager.ts- Preserve and pass model contextsrc/agents/librarian.ts- Convert to factory with configurable modelsrc/agents/utils.ts- Use librarian factorysrc/tools/background-task/tools.ts- Capture and pass model contextassets/oh-my-opencode.schema.json- Regenerated JSON schemaRelated Issues
Closes #191
Additional Notes
This is a targeted fix addressing the core issue without over-engineering. The solution:
Future work could include making all agents use factory patterns and adding global model persistence configuration options, but this PR focuses on fixing the immediate bug.